package me.xujl;


import java.io.IOException;
import java.util.Properties;

import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.env.PropertiesPropertySource;
import org.springframework.core.io.support.PropertiesLoaderUtils;


/**
 * User: xujl
 * Date: 2014/3/28
 */
public class Main extends org.apache.camel.spring.Main {

    public static void main(String[] args) throws Exception {
        ApplicationContextInitializer<ClassPathXmlApplicationContext> initializer = new ApplicationContextInitializer<ClassPathXmlApplicationContext>() {
            @Override
            public void initialize(ClassPathXmlApplicationContext applicationContext) {
                try {
                    Properties props = PropertiesLoaderUtils.loadAllProperties("application.properties");
                    applicationContext.getEnvironment().getPropertySources().addFirst(new PropertiesPropertySource("test", props));
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        };

        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(new String[]{"applicationContext.xml"}, false);
        initializer.initialize(applicationContext);
        applicationContext.refresh();

        //20年...
        Thread.sleep(1000*86400*20);
    }

}
